<html>
<script>

var iframe;

window.addAndTransferIframe = function()
{
    iframe = document.createElement('iframe');
    iframe.setAttribute('width', '500');
    iframe.setAttribute('height', '350');
    iframe.setAttribute('src', 'iframe-reparenting-close-window-iframe.html');
    window.document.body.appendChild(iframe);
}

// Called from Iframe when it is loaded and initialized.
window.transferIframe = function()
{
   var backgroundWin = window.opener;
   backgroundWin.log("Transferring Iframe now.");
   backgroundWin.document.adoptNode(iframe);
   backgroundWin.document.body.appendChild(iframe);
   iframe.contentWindow.finish();
   window.close();
}
</script>

<body>
</body>
</html>